package ylesanded.hangman;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

/**
 * @author joosep.pollumae
 * Methods for object HangString
 */
public class HangString {
	
	/**
	 * local variable for String. 
	 */
	private String str;
	
	/**
	 * @return String str.
	 * Getter for HangString
	 */
	public String getStr() {
		return str;
	}
	
	/**
	 * @param string
	 * Constructor for HangString class
	 */
	public HangString(String string) {
		this.str = string;
	}
	
	/**
	 * @return distinct size of HangString
	 */
	public int getDistinctCharNum() {
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < str.length(); i++) {
			String ch = (str.charAt(i) + "").toUpperCase();
			if (!list.contains(ch) && str.charAt(i) != ' ' 
				&& str.charAt(i) != '-') {
				list.add(ch);
			}	
		}
		return list.size();
	}
	
	/**
	 * @return true if inserted is only letters with space and "-"
	 */
	public boolean isValid() {
		return StringUtils.isAlphaSpace(str.replaceAll("-", ""));
		
	}

}
